package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "互动问题管理端相关接口")
@RestController
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
public class InteractionQuestionAdminController {

    private final IInteractionQuestionService questionService;

    /**
     * 管理端分页查询问题
     *
     * @param pageQuery 查询条件
     * @return
     */
    @GetMapping("page")
    @ApiOperation("用户端分页查询问题")
    public PageDTO<QuestionAdminVO> queryQuestionPage(QuestionAdminPageQuery pageQuery){
        return questionService.queryAdminQuestionPage(pageQuery);
    }

    /**
     *  管理端根据id查询问题详情 练习一
     * @param id 问题id
     * @return
     */
    @GetMapping("{id}")
    @ApiOperation("管理端根据id查询问题详情")
    public QuestionAdminVO queryById(@PathVariable Long id){
        return questionService.queryAdminById(id);
    }

    /**
     *  管理端隐藏或显示问题 练习二
     * @param id 问题的id
     * @param hidden 是否隐藏
     */
    @PutMapping("/{id}/hidden/{hidden}")
    @ApiOperation("管理端隐藏或显示问题")
    public void showOrHidden(@PathVariable("id")Long id,@PathVariable("hidden")Boolean hidden){
        questionService.showOrHidden(id,hidden);
    }

}
